package com.pdg.mcplugin.spawnsurance.commandprocessors;

import com.pdg.mcplugin.spawnsurance.PermissionChecker;

public enum Property {
	ACCELERATION("ACCELERATION","Acceleration",PermissionChecker.permissionAdminConfiguration),
	CLAIMS("CLAIMS","Claims",PermissionChecker.permissionUse,PermissionChecker.permissionAdminClaims),
	MATERIAL("MATERIAL","Material",PermissionChecker.permissionAdminConfiguration),
	MAXIMUM("MAXIMUM","Maximum",PermissionChecker.permissionAdminConfiguration),
	MESSAGE_ENABLED("MESSAGE-ENABLED","Message Enabled",PermissionChecker.permissionAdminConfiguration),
	MESSAGE_TEXT("MESSAGE-TEXT","Message Text",PermissionChecker.permissionAdminConfiguration),
	MINIMUM("MINIMUM","Minimum",PermissionChecker.permissionAdminConfiguration),
	PAY_SOURCE("PAY-SOURCE","Pay Source",PermissionChecker.permissionAdminConfiguration),
	FILTER_STATE("FILTER-STATE","Filter State",PermissionChecker.permissionUse,PermissionChecker.permissionAdminConfiguration),
	FILTER_MATERIALS("FILTER-MATERIALS","Filter Materials",PermissionChecker.permissionUse,PermissionChecker.permissionAdminConfiguration),
	//not part of the get/set chain
	CLAIMS_FOR("CLAIMS-FOR","Claims For",PermissionChecker.permissionAdminClaims),
	INVALID(null,null,null);
	private String permissionSet;
	private String permissionGet;
	private String label;
	private String text;
	Property(String theText,String theLabel,String theGetPermission,String theSetPermission){
		setText(theText);
		setLabel(theLabel);
		setGetPermission(theGetPermission);
		setSetPermission(theSetPermission);
	}
	private void setSetPermission(String theSetPermission) {
		permissionSet = theSetPermission;
	}
	private void setGetPermission(String theGetPermission) {
		permissionGet = theGetPermission;
	}
	private void setLabel(String theLabel) {
		label = theLabel;
	}
	private void setText(String theText) {
		text = theText;
	}
	Property(String theText,String theLabel,String theGetSetPermission){
		setText(theText);
		setLabel(theLabel);
		setGetPermission(theGetSetPermission);
		setSetPermission(theGetSetPermission);
	}
	public String getText(){
		return text;
	}
	public String getLabel(){
		return label;
	}
	public String getGetPermission(){
		return permissionGet;
	}
	public String getSetPermission(){
		return permissionSet;
	}
	
	private final static Property[] properties = new Property[]{ACCELERATION, MATERIAL, CLAIMS, MAXIMUM, MINIMUM, MESSAGE_ENABLED, MESSAGE_TEXT, PAY_SOURCE,FILTER_STATE,FILTER_MATERIALS};
	
	public static Property parse(String theText){
		for(int index=0;index<properties.length;++index){
			if(properties[index].getText().compareToIgnoreCase(theText)==0){
				return properties[index];
			}
		}
		return INVALID;
	}
}
